home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-20 | 6.3 KB | 183 lines | [TEXT/R*ch] |
- Speech Daemon GH v 1.0.2 by Glenn R. Howes 4/20/94
- based on the sample daemon by C.K. Haun provided with Develop Issue#9
- =======================
-
- Description:
- Speech Daemon GH is a small background only application which is designed to
- give speech capability to programs, such as INIT's, control panels, apple scripts,
- and programs running on remote computers. It can be interface through either
- the Program to Program Communications Toolbox (PPC) or via the AppleEventâ„¢
- mechanism. I've written two separate programs, Speech Note GH 2.0 and Remote
- Speak GH 1.0, which make use of these abilities.
-
- If you make frequent use of the Daemon, it is most convenient to put an alias to
- it into your StartUp Items folder (which is in your System Folder).
-
- ======================
-
- Requirements:
- System 7, the Speech Manager. The Daemon will run happily in a 50k partition,
- however, to use the Macintalk Pro voices a partition of 220 to 300k is required.
- If there isn't enough room, the daemon will use the system voice (Marvin?).
- It is highly recommended that you install Sound Manager 3.0, as it will
- minimize interference with system beeps and other sounds.
-
- ** It appears as if the daemon is incompatible with Star Trek the 25th aniversary
- ** game. I'm not placing blame and I'm looking for a solution.
-
- ** When running, there will be no icon for Speech Daemon GH displayed under
- ** the application menu.
-
- ** Just because the Daemon's icon is dimmed does not mean it is currently
- ** running--although if it is undimmed, the Daemon is definitely not running.
- ** This is a Finder bug. You can do a Get Info on the Daemon's icon
- ** and if you can change the partition size, the daemon is not running.
-
- ** Holding the shift key down just after the desktop appears during startup will
- ** prevent the items in the startup items folder from launching.
-
-
- =======================
- Limitations:
- The Daemon can only speak one string at a time and have one string pending. It can
- only speak chunks 255 characters or less. It can only process one string at a time
- from AppleScript with nothing pending. If you want a more elaborately scriptable
- Daemon, I would suggest SpokesDaemon by Eric Weidl; I'm sure he would appreciate
- the shareware fee.
-
- ====================
- AppleScripting:
- The daemon has an 'aete' resource, so you can just use Apple's Script Editor to get
- a list of the commands the daemon supports.
-
- ====================
- Programming:
-
- If you as a programmer want to interface with this daemon from your own code
- using PPC calls, you will need to examine the following sample code for a synchronous
- call to the daemon:
-
- /* Most of this was taken from sample code provided on the Develop CD under the
- ** title "Sample Control Panel Device and INIT Combination"
- **/
- #define kDaemonVersion 1
- typedef struct MyVoiceInfo
- {
- short version;
- Fixed volume;
- Fixed rate;
- Fixed modulation;
- Fixed pitch;
- VoiceSpec theVoice;
- Str255 string2Speak;
- Boolean keepVoice;
- unsigned long waitTime; // time in ticks which the daemon should delay before speaking
- unsigned long ticks; // system tick count when the daemon was called (zero is fine).
- } MyVoiceInfo, *MyVoiceInfoPtr, **MyVoiceInfoH;
-
-
- typedef struct {
- PPCParamBlockRec pb;
- PPCPortRec portName;
- LocationNameRec locationName;
- Str255 userName;
- char buffer[512];
- } SessionRecord, *SessionPtr;
-
-
- #define kSpeakString 1000 // use PPC toolbox to send a MyVoiceInfo record to daemon
- #define kNotifString 8888 // use PPC toolbox to send a Str255 to daemon to show notification box
- #define kShutUp 1005 // use PPC toolbox to pass unsigned long containing ticks value for the
- // MyVoiceInfo record you want to shut up
-
- #define DAEMON_NAME "\pSpeech Daemon (PPC)"
- #define TEST_STRING "\pWatson, come here. I need you."
-
- #define CREATOR 'IF 8' // I went to International Falls Senior High & my
- // football jersey # was 8 (ok, I was the statistician,
- // but I still wore a jersey)
- /* HandleTest will speak a string using the parameters passed to it in the
- ** record vInfo points to. */
-
- void HandleTest( MyVoiceInfoPtr vInfo)
- {
- OSErr iErr;
- short refNum;
- Str255 aString;
- SessionRecord sessionRecord;
- iErr = OpenAPort(&refNum);
- if(iErr)
- {
- SysBeep(8);
- }
- else
- {
- BlockMove(TEST_STRING, &vInfo->string2Speak, sizeof(TEST_STRING));
-
-
- sessionRecord.portName.nameScript = smRoman;
- BlockMove( DAEMON_NAME, sessionRecord.portName.name, sizeof( DAEMON_NAME));
-
- sessionRecord.portName.portKindSelector = ppcByCreatorAndType;
- sessionRecord.portName.u.port.creator = CREATOR;
- sessionRecord.portName.u.port.type = 'APPL';
-
- sessionRecord.pb.startParam.ioCompletion = 0L;
- sessionRecord.pb.startParam.portRefNum = refNum;
- sessionRecord.pb.startParam.serviceType = ppcServiceRealTime;
- sessionRecord.pb.startParam.resFlag = 0;
- sessionRecord.pb.startParam.portName = &sessionRecord.portName;
- sessionRecord.pb.startParam.locationName = nil;
- sessionRecord.pb.startParam.userData = kSpeakString;
- sessionRecord.pb.startParam.userRefNum = 0; /* guest access? */
-
- iErr = PPCStart(&sessionRecord.pb.startParam,FALSE);
-
-
- if (iErr == noErr)
- {
- sessionRecord.pb.writeParam.ioCompletion = 0L;
- sessionRecord.pb.writeParam.bufferLength = sizeof (MyVoiceInfo);
- sessionRecord.pb.writeParam.bufferPtr = (Ptr) vInfo;
- sessionRecord.pb.writeParam.more = false;
- iErr = PPCWrite(&sessionRecord.pb.writeParam,FALSE);
- }
- else
- {
- SysBeep(8);
- }
-
- iErr = PPCEnd(&sessionRecord.pb.endParam, false); // make sure transfer is done
- iErr = PPCClose(&sessionRecord.pb.closeParam, false); // close open port
- }
- }
- #define CODE_TYPE 'APPL' // put in your programs type
- #define CODE_CREATOR '????' // put in your creator type
- #define CODE_NAME "\pUntitled Port"
- OSErr OpenAPort(short *refNum)
- {
- PPCPortRec thePort;
- PPCOpenPBRec pb;
- OSErr err;
- Str255 portName;
-
- thePort.nameScript = smRoman;
- BlockMove(CODE_NAME, thePort.name, sizeof(CODE_NAME));
- thePort.portKindSelector = ppcByCreatorAndType;
- thePort.u.port.creator = CODE_CREATOR;
- thePort.u.port.type = CODE_TYPE;
-
- pb.ioCompletion = nil;
- pb.serviceType = ppcServiceRealTime;
- pb.resFlag = 0;
- pb.networkVisible = false;
- pb.portName = &thePort;
- pb.locationName = nil; // use the default location
-
- err = PPCOpen(&pb, false);
- if (err) return(err);
-
- *refNum = pb.portRefNum;
- return(noErr);
- }
-